package com.lc.config.interceptor;

import com.lc.bean.User;
import com.lc.config.JWTUntil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Component
public class Interceptor2 implements HandlerInterceptor {
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private JWTUntil jwtUntil;
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
       String usertoken=(String) redisTemplate.opsForValue().get("usertoken");
        User user=(User) redisTemplate.opsForValue().get("user");
      String xx= jwtUntil.verify(usertoken,user.getName());
      if (xx.equals("success")){
          System.out.println("hh");
        return true;}
      return false;
    }
}
